import HomeImg from "./assets/home.png";
import SelectHomeImg from "./assets/home-select.png";
import NewImg from "./assets/new.png";
import MyImg from "./assets/my.png";
import SelectNewImg from "./assets/new-select.png";
import SelectMyImg from "./assets/my-select.png";

export interface TarItemData {
  /**
   * @description 默认图标
   *
   * @type {string}
   * @memberof TarItemData
   */
  icon: string;

  /**
   * @description 选中图标
   *
   * @type {string}
   * @memberof TarItemData
   */
  selectIcon: string;

  /**
   * @description 跳转路由
   *
   * @type {string}
   * @memberof TarItemData
   */
  url: string;
  /**
   * @description 文字
   *
   * @type {string}
   * @memberof TarItemData
   */
  text: string;

  /**
   * @description 是否显示红点
   */
  isShowRedDot: boolean;
}

let config: TarItemData[];

/**
 * @description 设置底部配置数据
 */
export const setConfig = (data: TarItemData[]) => {
  config = data;
};

export const setTabBarRedDot = (index: number, isShow: boolean) => {
  if (index >= 0 && index < config.length) {
    config[index].isShowRedDot = isShow;
  }
};

export { config };

export interface Data {
  /**
   * @description 当前选中链接
   */
  activeUrl: string;
  config: TarItemData[];
}

export const getState = () => {
  const config = [
    {
      icon: HomeImg,
      selectIcon: SelectHomeImg,
      url: "/",
      text: "首页",
      isShowRedDot: false,
    },
    {
      icon: NewImg,
      selectIcon: SelectNewImg,
      url: "/new",
      text: "消息",
      isShowRedDot: false,
    },
    {
      icon: MyImg,
      selectIcon: SelectMyImg,
      url: "/my",
      text: "我的",
      isShowRedDot: false,
    },
  ];

  return {
    activeUrl: "",
    config,
  };
};
